<nav class="navbar navbar-default navbar-static-top">
    <div class="container">
        <div class="navbar-header">

            <!-- Collapsed Hamburger -->
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
                <span class="sr-only">Toggle Navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>

            <!-- Branding Image -->
            <a class="navbar-brand" href="{url('root')}">
                TPBlog
            </a>
        </div>

        <div class="collapse navbar-collapse" id="app-navbar-collapse">
            <!-- Left Side Of Navbar -->
            <ul class="navbar-nav mr-auto">
                <li class="nav-item <?php echo(navbar_class('topic', 'index')) ?>">
                    <a class="nav-link" href="{:url('topic/index')}">话题</a>
                </li>
                <li class="nav-item <?php echo(navbar_class('category', 'read', ['id' => 1])) ?>">
                    <a class="nav-link" href="{:url('category/read', ['id' => 1])}">分享</a>
                </li>
                <li class="nav-item <?php echo(navbar_class('category', 'read', ['id' => 2])) ?>">
                    <a class="nav-link" href="{:url('category/read', ['id' => 2])}">教程</a>
                </li>
                <li class="nav-item <?php echo(navbar_class('category', 'read', ['id' => 3])) ?>">
                    <a class="nav-link" href="{:url('category/read', ['id' => 3])}">问答</a>
                </li>
                <li class="nav-item <?php echo(navbar_class('category', 'read', ['id' => 4])) ?>">
                    <a class="nav-link" href="{:url('category/read', ['id' => 4])}">公告</a>
                </li>
            </ul>

            <!-- Right Side Of Navbar -->
            <ul class="nav navbar-nav navbar-right">
                <!-- Authentication Links -->
                {empty name="current_user"}
                    <li><a href="{:url('login/create')}">登录</a></li>
                    <li><a href="{:url('register/create')}">注册</a></li>
                {else /}
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                            <img src="{$current_user->avatar}" class="img-responsive img-circle" width="30px" height="30px">
                            {$current_user->name} <span class="caret"></span>
                        </a>

                        <ul class="dropdown-menu" role="menu">

                            <li>
                                <a href="{:url('user/read', ['id' => $current_user->id])}">
                                    <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                                    个人中心
                                </a>
                            </li>
                            <li>
                                <a href="{:url('user/edit', ['id' => $current_user->id])}">
                                    <span class="glyphicon glyphicon-edit" aria-hidden="true"></span>
                                    编辑资料
                                </a>
                            </li>
                            <li>
                                <a href="#" onclick="event.preventDefault();document.getElementById('logout-form').submit();">
                                    <span class="glyphicon glyphicon-log-out" aria-hidden="true"></span>
                                    退出登录
                                </a>

                                <form id="logout-form" action="{:url('logout')}" method="POST" style="display: none;">
                                    {:token()}
                                </form>
                            </li>
                        </ul>
                    </li>
                {/empty}
            </ul>
        </div>
    </div>
</nav>